import React, { useEffect } from 'react'
import { Input } from 'antd'
import Request from '@/api/request'
import config from 'config/api'
import { data } from './data'

const Shop = () => {

  useEffect(() => {
    // Request.get('/h5/couponActivity/157', 'zbdxApi').then(res => {
    //   console.log('[ res ]', res)
    // })

    const { content } = data
    let allChild = content && Array.isArray(content) && content.reduce((prevArr, item, index) => {
      if (item.trendRecords && Array.isArray(item.trendRecords)) {
        if(item.trendRecords.length + prevArr.length <= 4) {

          prevArr.push(...item.trendRecords)
        } else {
          let difference = 4 - prevArr.length
          prevArr.push(...item.trendRecords.splice(0, difference))
        }
      }
      console.log('[ prevArr, item, index ]', prevArr, item, index)

      return prevArr
    }, [])
    console.log('[ data ]', data, allChild)

  }, [])

  return (
    <div>
      <Input />
    </div>
  )
}
export default Shop